package hn.cch.agent;


import com.sun.tools.attach.VirtualMachine;

public class TestAgent {


    public static void main(String[] args) {
        String pid = "22512";
        String agentPath = "D:\\chchen\\project\\jvm\\java\\java-project\\agent-jar\\target\\agent.jar";
        try {
            // Java 1.8:${JAVA_HOME}/lib/tools.jar
            VirtualMachine vm = VirtualMachine.attach(pid);
            vm.loadAgent(agentPath, "arg1");
            vm.detach();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
